<template>
    <div>
   <h1>新增康复理疗信息</h1>
<table class="table">
    <tbody>
        <tr>
            <td>项目名称</td>
            <td><input type="text" v-model="Adddata.name"></td>
        </tr>
        <tr>
            <td>服务时长</td>
            <td><input type="text" v-model="Adddata.num"></td>
        </tr>
        <tr>
            <td>服务人数</td>
            <td>
             <input type="text" v-model="Adddata.number"></td>
        </tr>
      
        <tr>
            <td>佣金(元)</td>
            <td><input type="text" v-model="Adddata.money"></td>
        </tr>
        <tr>
            <td>状态</td>
             <td> 
                  <input type="radio" name="AAA" :value=true v-model="Adddata.state">启用
                  <input type="radio" name="AAA" :value=false v-model="Adddata.state">禁用
            </td>
        </tr>
          <tr>
            <td>项目说明</td>
            <td>
              <textarea v-model="Adddata.hing"></textarea>
            </td>
        </tr>
     
         <tr>
            <td></td>
            <td><input type="button" value="保存" class="btn btn-success"  @click="Add"></td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import {ref}from 'vue'
import { useRouter } from 'vue-router';

//跳转数组
const router=useRouter()



//添加数据
const Adddata=ref({
   "isdel": true,
  "createId": 0,
  "createtime": "2025-07-14T08:44:26.313Z",
  "deleteId": 0,
  "deletetime": "2025-07-14T08:44:26.313Z",
  "updateId": 0,
  "updatetime": "2025-07-14T08:44:26.313Z",
  "id": 0,
  "name": "",
  "code": "",
  "num": "",
  "number": "",
  "money": "",
  "state": true,
  "hing": ""
})

//添加
const Add=()=>{
    if(Adddata.value.name=="")
    {
        alert("项目名称不能为空");
        return;
    }
     if(Adddata.value.num=="")
    {
        alert("服务时长不能为空");
        return;
    }
     if(Adddata.value.number=="")
    {
        alert("服务人数不能为空");
        return;
    }
     if(Adddata.value.money=="")
    {
        alert("佣金不能为空");
        return;
    }
    axios.post("/api/Hption/AddHop",Adddata.value).then(res=>{
        if(res.data>0)
        {
         alert("添加成功")   
        router.push("/Show")
        }
        else
        {
            alert("添加失败");
        }
    })
}














</script>

<style scoped>

</style>